import { tokenType } from '@/types/data';
import { loginAction } from '@/types/store';
import { getToken } from '@/utils/tokens';

const init: tokenType = getToken();
export default function login(state = init, action: loginAction): tokenType {
  switch (action.type) {
    case 'login/login':
      return action.payload;
    case 'login/logout':
      return { token: '', refresh_token: '' };
    default:
      return state;
  }
}
